package com.by.common.exception;

/**
 * 错误码枚举类
 */
public enum ErrorCode {
    
    // 系统级别错误
    SYSTEM_BUSY(1001, "系统繁忙，请稍后再试"),
    
    // 商品相关错误
    GOODS_REQUEST_FREQUENT(1002, "商品请求过于频繁，请稍后再试"),
    GOODS_NOT_EXIST(1003, "商品不存在"),
    GOODS_STOCK_INSUFFICIENT(1005, "商品库存不足"),
    
    // 用户相关错误
    USER_NOT_EXIST(1004, "用户不存在"),
    
    // 订单相关错误
    ORDER_CREATE_FAILED(1009, "创建订单失败"),
    ORDER_STOCK_DECREASE_FAILED(1006, "扣减库存失败"),
    
    // 秒杀相关错误
    SECKILL_FREQUENT(1007, "秒杀请求过于频繁，请稍后再试"),
    SECKILL_DUPLICATE(1008, "您已参与过秒杀，不能重复秒杀"),
    SECKILL_SOLD_OUT(1010, "商品已售罄"),
    
    // 限流相关错误
    RATE_LIMIT_USER_ORDER(1011, "用户下单频率过高，请稍后再试"),
    RATE_LIMIT_GOODS_VISIT(1012, "商品访问频率过高，请稍后再试"),
    
    // 参数相关错误
    PARAM_INVALID(1013, "参数无效");
    
    private final int code;
    private final String message;
    
    ErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }
    
    public int getCode() {
        return code;
    }
    
    public String getMessage() {
        return message;
    }
    
    @Override
    public String toString() {
        return code + ": " + message;
    }
}